<div class="container-fluid">
    <h4 class="content-head">家长信息</h4>
    <div class="table-wrapper users-table section">
        <div class="input-group" id="search">
            &nbsp;<label for="realname">家长姓名：</label>
            <input type="text" name="realname" class="input-small" id="realname">
            <label for="mobile">&nbsp;家长电话：</label>
            <input type="text" name="mobile" class="input-small" id="mobile">
            <label for="idcard">&nbsp;身份证号码：</label>
            <input type="text" name="idcard" class="input-medium" id="idcard">
            <span class="btn_area">
           <button id="search_btn" type="button" class="btn btn-purple btn-sm">
               搜索
               <i class="icon-search icon-on-right bigger-110"/>
           </button>
       </span>
        </div>
        <div id="list"></div>
    </div>
</div>

<script>
    (function () {
        var url = 'user/list-data';
        var $datagrid = $('#list');

        loadData();

        $('#search_btn').on('click', function () {
            loadData();
        });

        function loadData() {
            $datagrid.datagrid({
                action: false,
                'dataModel': {
                    'url': url,
                    'parameters': getCommJsonParams('search')
                },
                'columns': [
                    {title: '家长姓名', dataField: 'realname'},
                    {title: '家长性别', dataField: 'sexDict'},
                    {title: '联系电话', dataField: 'mobile'},
                    {title: '身份证号', dataField: 'idcard'},
                    {title: '家庭地址', dataField: 'address'},
                    {title: '注册日期', dataField: 'createTime'},
                    {title: '操作', render:function(data){
                         return "<a href='javascript:void(0);' onclick='resetPwd("+data.id+")'>重置登录密码</a>";
                    }}
                ]
            });
        };




    })();

     function resetPwd(userId){
            layer.confirm('重置为手机号后四位？',function () {
                 $.post('user/resetPwd', {"userId":userId}, function (result) {
                    if (result.success) {
                        layer.msg('重置成功', {icon: 1});
                    } else {
                        layer.msg('重置失败', {icon: 5});
                    }
                }, 'json');
              })
     }

</script>
